<template>
	<view class="content">
		<u-empty v-if="!info&&!loading" text="获取失败了..." mode="search"></u-empty>
		<view v-if="info&&!loading">
			<view class="title">
				<input type="text" :disabled="true" :value="info.title" placeholder="起个名字吧~" placeholder-style="color:#fff" />
			</view>
			<view class="info">
				<view>{{info.info}}</view>
				<view class="image">
					<image :src="info.image" mode="widthFix"></image>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: null,
				info: null,
				loading: false
			};
		},
		
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option.id); //打印出上个页面传递的参数。
			this.id = option.id
			this.getInfo()
		},
		methods: {
			async getInfo() {
				this.loading=true
				uni.showLoading({
					title: '加载中...',
				})
				let result = await uniCloud.callFunction({
					name: 'getListInfo',
					data: {
						type: 'oneinfo',
						id: this.id
					}
				})	
				this.loading=false
				uni.hideLoading()
				if (result.success) {

					this.info = result.result.data[0]
					console.log(this.info)
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		min-height: 100vh;
	}

	.title {
		padding: $page-padding;
		padding-top: 30rpx;
		padding-bottom: 30rpx;
		display: flex;
		background-color: $u-type-primary;
		color: #fff;
		font-size: 30rpx;
		align-items: center;
		justify-content: space-between;

		input {
			flex: 1;
		}
	}

	.info {
		padding: $page-padding;
		padding-top: 30rpx;
		padding-bottom: 30rpx;
		letter-spacing: 5rpx;
		line-height: 2.5;

		.image {
			margin-top: 50rpx;

			image {
				width: 100%;
			}
		}
	}
</style>
